home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The PC-SIG Library 10
/
The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso
/
PC_SIGCD
/
02
/
3
/
DISK0238.ZIP
/
CVTBIN.BAS
< prev
next >
Wrap
BASIC Source File
|
1984-10-06
|
2KB
|
76 lines
10 ' CVTBIN.BAS
20 '
30 ' Written by Wes Meier (76703,747)
40 '
50 ' Version 082584
60 '
70 ' Converts CIS (Intel HEX format) .BIN files to true Binary files. **YOU**
80 ' have to decide whether the file is a .COM or .EXE file.
90 '
100 KEY OFF
110 COLOR 6,1,1
120 CLS
130 DEFINT A-Z
140 FF = 256
150 PRINT TAB(21)"CVTBIN ...by Wes Meier (76703,747)..."
160 PRINT
170 N$ = "0123456789ABCDEF"
180 DEF FN H(X$) = 16 * (INSTR(N$, LEFT$(X$,1)) - 1) + INSTR(N$, RIGHT$(X$,1)) - 1
190 ON ERROR GOTO 580
200 INPUT "Input filespec: ";INPUTFILE$
210 IF INPUTFILE$ = "" THEN END
220 OPEN"I",1,INPUTFILE$
230 INPUT "Output filespec: ";OUTPUTFILE$
240 IF OUTPUTFILE$ = "" THEN END
250 OPEN"I",2,OUTPUTFILE$
260 CLOSE 2
270 PRINT OUTPUTFILE$" already exists. Overwrite it?"
280 X$ = INPUT$(1)
290 IF X$ < > "Y" AND X$ < > "y" THEN 230
300 OPEN OUTPUTFILE$ AS 2 LEN=1
310 FIELD 2, 1 AS T$
320 PRINT
330 PRINT "Working...."
340 LNUM = 0
350 WHILE NOT EOF(1)
360 LNUM = LNUM + 1
370 INPUT #1,A$
380 IF LEN(A$) = 0 THEN 510
390 IF LEFT$(A$,1) < > ":" THEN ERROR 80
400 IF LEN(A$) - 11 < > 2 * FN H(MID$(A$,2,2)) THEN ERROR 81
410 CS = 0
420 FOR X = 2 TO LEN(A$) - 2 STEP 2
430 T = FN H(MID$(A$,X,2))
440 CS = T + CS
450 IF X > 9 THEN LSET T$ = CHR$(T) : PUT 2
460 NEXT
470 CS = CS MOD 256
480 ACS = FF - FN H(RIGHT$(A$,2))
490 IF CS < > ACS AND CS < > 0 THEN ERROR 82
500 WEND
510 CLOSE
520 PRINT
530 PRINT "Conversion complete."
540 END
550 '
560 ' Error Trapping Routines
570 '
580 IF ERL = 220 THEN PRINT INPUTFILE$" not found." : RESUME 200
590 IF ERL = 250 THEN RESUME 300
600 BEEP
610 IF ERR = 80 THEN RESUME 650
620 IF ERR = 81 THEN RESUME 670
630 IF ERR = 82 THEN RESUME 690
640 ON ERROR GOTO 0
650 PRINT INPUTFILE$" is not a .BIN file. Missing "CHR$(34)":"CHR$(34)". ";
660 GOTO 710
670 PRINT "Data length error. Line length doesn't match.";
680 GOTO 710
690 PRINT "Checksum Error in line"LNUM"."
700 PRINT A$
710 PRINT " Program aborted."
720 CLOSE
730 KILL OUTPUTFILE$
740 END
750 ' of CVTBIN.BAS